package org.jeecg.modules.module.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.module.service.IStockService;
import org.jeecg.modules.module.vo.StockDetailVo;
import org.jeecg.modules.module.vo.StockListVo;
import org.jeecg.modules.module.vo.StockViewVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * @Title: stock
 * @Description: 股票接口
 * @Author chenxi
 * @Date 2024-02-25
 * @Version V1.0
 */
@Slf4j
@RestController
@RequestMapping("/stock")
@Api(tags="股票")
public class StockController {

	@Autowired
	IStockService stockService;

	/**
	 * 数据大屏
	 * 
	 * @return
	 */
	@RequestMapping(value = "/view", method = RequestMethod.GET)
	@ApiOperation("数据大屏")
	public Result<StockViewVo> view() {
		log.debug("----开始获取数据大屏------");
		StockViewVo stockViewVo = stockService.getView();
		log.debug("----数据大屏数据已获取------");
		return Result.ok(stockViewVo);
	}

	/**
	 * 行情列表
	 *
	 * @return
	 */
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	@ApiOperation("行情列表")
	public Result<List<StockListVo>> list() {
		log.debug("----开始获取行情列表------");
		List<StockListVo> stockListVo = stockService.getList();
		log.debug("----行情列表数据已获取------");
		return Result.ok(stockListVo);
	}

	/**
	 * 股票详情
	 *
	 * @return
	 */
	@RequestMapping(value = "/detail", method = RequestMethod.GET)
	@ApiOperation("股票详情")
	public Result<StockDetailVo> detail(@RequestParam("code")@NotEmpty(message = "股票代码不能为空！") String code
							,@RequestParam("type")@NotEmpty(message = "K线分类不能为空！") String type) {
		log.debug("----开始获取股票详情------");
		StockDetailVo detailVo = stockService.detail(code,type);
		log.debug("----股票详情数据已获取------");
		return Result.ok(detailVo);
	}


}
